package jz.service.svr;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

public class DateTools {

	public static String dateFormat(Date date,String format){
		DateFormat fm = new SimpleDateFormat(format);
		return fm.format(date);
	}
	
	public static Date stringFormat(String str,String format){
		DateFormat fm = new SimpleDateFormat(format);
		Date date = null;
		try {
			date = fm.parse(str);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return date;
	}
	
	public static Date moveDate(Date date,int field, int amount){
		Calendar calendar = new GregorianCalendar();
		calendar.setTime(date);
		calendar.add(field, amount);
		return date = calendar.getTime();
	}
	public static void main(String[] args) {
		Date br = DateTools.stringFormat("19841008", "yyyyMMdd");
		System.out.println(br);
		
		System.out.println("mxz12".substring(3));
		
	}
}
